package cz.cizek.tutorials.designpatterns.immutableobject.wrong_non_immutable;

/**
 * @author jcizek
 */
public class NonImmutableFraction {

    private int numerator; //citatel
    private int denominator; //jmenovatel

    public NonImmutableFraction(int numerator, int denominator) {
        this.numerator = numerator;
        this.denominator = denominator;
    }

    //------------------------------------------------PUBLIC METHODS----------------------------------------------------

    /**
     * Vrati soucin zlomku
     */
    public NonImmutableFraction multiply(NonImmutableFraction fraction) {
        numerator *= fraction.getNumerator();
        denominator *= fraction.getDenominator();
        return this;
    }

    public int getNumerator() {
        return numerator;
    }

    public int getDenominator() {
        return denominator;
    }

    @Override
    public String toString() {
        return "NonImmutableFraction{" +
                "denominator=" + denominator +
                ", numerator=" + numerator +
                '}';
    }
}
